<?php
/**
 * Copyright 2011 Facebook, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may
 * not use this file except in compliance with the License. You may obtain
 * a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

require 'sdk/src/facebook.php';

// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
  'appId'  => '340189982730332',
  'secret' => 'af9630304dee11ece67b092617036205',
));

// Get User ID
$user = $facebook->getUser();

// We may or may not have this data based on whether the user is logged in.
//
// If we have a $user id here, it means we know the user is logged into
// Facebook, but we don't know if the access token is valid. An access
// token is invalid if the user logged out of Facebook.

if ($user) {
  try {
    // Proceed knowing you have a logged in user who's authenticated.
    $user_profile = $facebook->api('/me');
  } catch (FacebookApiException $e) {
    echo 'Error:\n';
    var_dump($e);
    error_log($e);
    $user = null;
  }
}

// Login or logout url will be needed depending on current user state.
if ($user) {
  $logoutUrl = $facebook->getLogoutUrl();
  ?>
  <a href="<?php echo  $logoutUrl;?>">Logout</a>
  <?php
} else {
  $loginUrl = $facebook->getLoginUrl();
   ?>
  <a href="<?php echo  $loginUrl;?>">Login</a>
  <?php
  
}

// This call will always work since we are fetching public data.
$naitik = $facebook->api('/naitik');
//test
var_dump($user);
?>

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
    <script src="<?php
 
echo $base_url . 'content/scripts/jquery-1.7.2.js'

?>" type="text/javascript"></script>
    <script src="<?php

echo $base_url . 'content/scripts/core.js'

?>" type="text/javascript"></script>
	<title>Welcome to CodeIgniters</title>

	<style type="text/css">

	::selection{ background-color: #E13300; color: white; }
	::moz-selection{ background-color: #E13300; color: white; }
	::webkit-selection{ background-color: #E13300; color: white; }

	body {
		background-color: #fff;
		
		font: 13px/20px normal Helvetica, Arial, sans-serif;
		color: #4F5155;
        margin: 0;
	}

	a {
		color: #003399;
		background-color: transparent;
		font-weight: normal;
	}

	h1 {
		color: #444;
		background-color: transparent;
		border-bottom: 1px solid #D0D0D0;
		font-size: 19px;
		font-weight: normal;
		margin: 0 0 14px 0;
		padding: 14px 15px 10px 15px;
	}

	code {
		font-family: Consolas, Monaco, Courier New, Courier, monospace;
		font-size: 12px;
		background-color: #f9f9f9;
		border: 1px solid #D0D0D0;
		color: #002166;
		display: block;
		margin: 14px 0 14px 0;
		padding: 12px 10px 12px 10px;
	}

	#body{
		margin: 0 15px 0 15px;
	}
	
	p.footer{
		text-align: right;
		font-size: 11px;
		border-top: 1px solid #D0D0D0;
		line-height: 32px;
		padding: 0 10px 0 10px;
		margin: 20px 0 0 0;
	}
	
	#container{
		margin: 10px;
		border: 1px solid #D0D0D0;
		-webkit-box-shadow: 0 0 8px #D0D0D0;
        width: 720px;
	}
    .overlay{
        width: 100%;
        height: 100%;
        background: black;
        position: absolute;
        opacity: 0.4;
        margin: 0;
        padding: 0;
        display: none;
    }
	</style>
</head>
<body >
<div class="overlay"></div>
<div id="container">

<h1>Welcome to Manager page</h1>

<div id="body" >